package com.yy.studymybatisplus;

import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.config.OutputFile;
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;

import java.util.Collections;

public class Generator {
    public static void main(String[] args) {
        FastAutoGenerator.create("jdbc:mysql://yang1yu.site:3306/mybatis_plus?characterEncoding=utf-8&userSSL=false", "root", "yang1yu")
                        .globalConfig(builder -> {
                            builder.author("yang1yu")
                                    .fileOverride() // 覆盖已生成文件
                                    .outputDir("E:\\CodeStudy\\Mybatis-Plus\\study-mybatis-plus\\generator"); // 指定输出目录
                        })
                        .packageConfig(builder -> {
                            builder.parent("com.yy") // 设置父包名
                                    .moduleName("mybatisplus") // 设置父包模块名
                                    .pathInfo(Collections.singletonMap(OutputFile.mapperXml, "E:\\CodeStudy\\Mybatis-Plus\\study-mybatis-plus\\generator"));
                        })
                        .strategyConfig(builder -> {
                            builder.addInclude("user"); // 设置需要生成的表名
//                                    .addTablePrefix("t_", "c_"); // 设置过滤表前缀
                        })
                        .templateEngine(new FreemarkerTemplateEngine()) // 使用Freemarker
                        .execute();
    }
}

